import BaseIndex from './baseIndex';

export default class property extends BaseIndex {
    constructor() {
        super();
        this.initExpand("property");
    }

    setIsVisible(props, action) {
        const { pageAxis } = props;
        const { targetPropertyName, isVisible } = action;
        if (!action.targetProperty) action.targetProperty = pageAxis.getProperty(targetPropertyName);
        if (!action.targetProperty) return;

        if (action.targetProperty.setIsVisible) action.targetProperty.setIsVisible(isVisible);
        else action.targetProperty.isVisible = isVisible;
    }

    playVideo(props, action) {
        const { pageAxis } = props;
        const { videoPlayerName, videoUrl } = action;
        if (!action.videoPlayer) action.videoPlayer = pageAxis.getProperty(videoPlayerName);
        if (!action.videoPlayer) return;

        if (action.videoPlayer.setVideoSrc) action.videoPlayer.setVideoSrc(videoUrl);
    }
}